<template>
    <view class="content">
        <view class="header">
            <image src="../../static/shilu-login/logo.png"></image>
        </view>
        <view class="list">
            <view class="list-call">
                <image class="img" src="/static/shilu-login/1.png"></image>
                <input class="sl-input" v-model="phone" type="number" maxlength="11" placeholder="请输入手机号"></input>
            </view>
            <view class="list-call">
                <image class="img" src="/static/shilu-login/2.png"></image>
                <input class="sl-input" v-model="password" type="text" maxlength="32" placeholder="请输入密码" password="true"></input>
            </view>
        </view>
        <view class="button-login" hover-class="button-hover" @click="bindLogin()">
            <text>登录</text>
        </view>
        <view class="agreement">
            <navigator url="forget" open-type="navigate">忘记密码</navigator>
            <text>......</text>
            <navigator url="reg" open-type="navigate">注册账户</navigator>
        </view>
    </view>
</template>
<script>
export default{
    data(){
        return{
            phone:'',
            password:''
        }
    },
    methods:{
        bindLogin(){
            if(this.phone.length != 11){
                uni.showToast({
                    icon:'none',
                    title:'手机号不正确'
                });
                return;
            }
            if(this.apssword.length < 3){
                uni.showToast({
                    icon:'none',
                    title:'密码不正确'
                });
                return;
            }
            uni.request({
                url:'http://47.102.217.172:8088/MobileShop5-1/member/login',
                header:{
                    'content-type':'application/x-www-form-urlencoded'
                },
                data:{
                    uname:this.phone,
                    password:this.password
                },
                method:'POST',
                dataType:'json',
                success:(res)=>{
                    console.log(res)
                    if(res.data.status != 0){
                        uni.showToast({
                            title:res.data.msg,
                            icon:'none'
                        })
                    }else{
                        uni.navigateTo({
                            url:'../index/index'
                        })
                    }
                }
            })
        }
    }
}
</script>